package com.studentsys.servlet;

import com.alibaba.fastjson.JSON;
import com.studentsys.bean.City;
import com.studentsys.service.CityService;
import com.sun.deploy.net.HttpRequest;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/city")
public class CityServlet extends BaseServlet{
    private CityService cs = new CityService();
    public void findCityByPid(HttpServletRequest req, HttpServletResponse resp) throws IOException {
        //获取省的pid编号
        String pid = req.getParameter("pid");
        //调用service查询方法
        List<City> list = cs.findCityByPid(Integer.parseInt(pid));
        //list-->json
        String str = JSON.toJSONString(list);
        //响应前端
        resp.getWriter().print(str);
    }
}
